<?php

class PageControl {

	var $paginas = array();
	var $selecionada = 0;

	function PageControl() {
	
		null;
	}
	
	// Add a new page to Page Control
	function addPage($nome,$selecionada=0) {
		$this->paginas[count($this->paginas)] = $nome;
	}
	
	// Select a page by name
	function selectPage($nome) {
		for($i=0;$i<count($this->paginas);$i++) {
			if($this->paginas[$i]==$nome) {
				$this->selecionada = $i;
			}
		}
	}
	
	// Select a page by index
	function selectPageIndex($numero) {
		$this->selecionada = $numero;
	}

	// generate page HTML
	function html() {
		$html = "";
		
		$html .= "<TABLE CELLPADDING=0 CELLSPACING=0>\n";
		$html .= "<TR>\n";
		for($i=0;$i<count($this->paginas);$i++) {
			if($i == $this->selecionada) {
				$html .= "<TD  style=\"font-family: arial; font-size: 12px; font-color: black\" background='guia0.png' width=129px height=20px>&nbsp;&nbsp;".$this->paginas[$i]."</TD>\n";
			}
			else {
				$html .= "<TD  style=\"font-family: arial; font-size: 12px; font-color: darkgray\" background='guia1.png' width=129px height=20px>&nbsp;&nbsp;".$this->paginas[$i]."</TD>\n";
			}
		}
		$html .= "</TR>\n";
		$html .= "</TABLE>\n";
		return $html;
	}
	
	// generate and print page HTML
	function show() {
		echo $this->html();	
	}

}

// PAGE SAMPLE
$P = new PageControl();
$P->addPage("Pesquisar");
$P->addPage("Editar");
$P->show();




?>